<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Rails::Rack::LogTailer</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" href="../../../css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../css/main.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../css/github.css" type="text/css" media="screen" />
<script src="../../../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../js/main.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>

</head>

<body>     
    <div class="banner">
        
            <span>Ruby on Rails v4.0.0</span><br />
        
        <h1>
            <span class="type">Class</span> 
            Rails::Rack::LogTailer 
            
                <span class="parent">&lt; 
                    
                    <a href="../../Object.html">Object</a>
                    
                </span>
            
        </h1>
        <ul class="files">
            
            <li><a href="../../../files/railties/lib/rails/rack/log_tailer_rb.html">railties/lib/rails/rack/log_tailer.rb</a></li>
            
        </ul>
    </div>
    <div id="bodyContent">
        <div id="content">
  


  


  
  


  


  
    <!-- Method ref -->
    <div class="sectiontitle">Methods</div>
    <dl class="methods">
      
        <dt>C</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="LogTailer.html#method-i-call">call</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>N</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="LogTailer.html#method-c-new">new</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>T</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="LogTailer.html#method-i-tail-21">tail!</a>
              </li>
            
          </ul>
        </dd>
      
    </dl>
  

  



  

    

    

    


    


    <!-- Methods -->
    
      <div class="sectiontitle">Class Public methods</div>
      
        <div class="method">
          <div class="title method-title" id="method-c-new">
            
              <b>new</b>(app, log = nil)
            
            <a href="LogTailer.html#method-c-new" name="method-c-new" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-c-new_source')" id="l_method-c-new_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/cf1f563473369c02917608e9b4c461328b6f8dac/railties/lib/rails/rack/log_tailer.rb#L4" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-c-new_source" class="dyn-source">
                <pre><span class="ruby-comment"># File railties/lib/rails/rack/log_tailer.rb, line 4</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">initialize</span>(<span class="ruby-identifier">app</span>, <span class="ruby-identifier">log</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-ivar">@app</span> = <span class="ruby-identifier">app</span>

  <span class="ruby-identifier">path</span> = <span class="ruby-constant">Pathname</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">log</span> <span class="ruby-operator">||</span> <span class="ruby-node">&quot;#{::File.expand_path(Rails.root)}/log/#{Rails.env}.log&quot;</span>).<span class="ruby-identifier">cleanpath</span>

  <span class="ruby-ivar">@cursor</span> = <span class="ruby-ivar">@file</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-keyword">if</span> <span class="ruby-operator">::</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">exists?</span>(<span class="ruby-identifier">path</span>)
    <span class="ruby-ivar">@cursor</span> = <span class="ruby-operator">::</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">size</span>(<span class="ruby-identifier">path</span>)
    <span class="ruby-ivar">@file</span> = <span class="ruby-operator">::</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">path</span>, <span class="ruby-string">'r'</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
                  
      <div class="sectiontitle">Instance Public methods</div>
      
        <div class="method">
          <div class="title method-title" id="method-i-call">
            
              <b>call</b>(env)
            
            <a href="LogTailer.html#method-i-call" name="method-i-call" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-call_source')" id="l_method-i-call_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/cf1f563473369c02917608e9b4c461328b6f8dac/railties/lib/rails/rack/log_tailer.rb#L16" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-call_source" class="dyn-source">
                <pre><span class="ruby-comment"># File railties/lib/rails/rack/log_tailer.rb, line 16</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">call</span>(<span class="ruby-identifier">env</span>)
  <span class="ruby-identifier">response</span> = <span class="ruby-ivar">@app</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
  <span class="ruby-identifier">tail!</span>
  <span class="ruby-identifier">response</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-tail-21">
            
              <b>tail!</b>()
            
            <a href="LogTailer.html#method-i-tail-21" name="method-i-tail-21" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-tail-21_source')" id="l_method-i-tail-21_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/cf1f563473369c02917608e9b4c461328b6f8dac/railties/lib/rails/rack/log_tailer.rb#L22" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-tail-21_source" class="dyn-source">
                <pre><span class="ruby-comment"># File railties/lib/rails/rack/log_tailer.rb, line 22</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">tail!</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@cursor</span>
  <span class="ruby-ivar">@file</span>.<span class="ruby-identifier">seek</span> <span class="ruby-ivar">@cursor</span>

  <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@file</span>.<span class="ruby-identifier">eof?</span>
    <span class="ruby-identifier">contents</span> = <span class="ruby-ivar">@file</span>.<span class="ruby-identifier">read</span>
    <span class="ruby-ivar">@cursor</span> = <span class="ruby-ivar">@file</span>.<span class="ruby-identifier">tell</span>
    <span class="ruby-identifier">$stdout</span>.<span class="ruby-identifier">print</span> <span class="ruby-identifier">contents</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
                    </div>

    </div>
  </body>
</html>    